from django.db import models
from note.models import Note
from django.contrib.auth import get_user_model
# Create your models here.
User = get_user_model()


class Comment(models.Model):
    note = models.ForeignKey(Note,on_delete=models.CASCADE,verbose_name='评论主题')
    user = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='评论用户')
    parent = models.ForeignKey('self',on_delete=models.CASCADE,verbose_name='回复的评论主题',null=True)
    body = models.TextField(verbose_name='评论内容')
    pub_date = models.DateTimeField(auto_now_add=True,verbose_name='评论时间')
    is_delete = models.BooleanField(verbose_name='是否删除',default=False)

    class Meta:
        verbose_name = '评论'
        verbose_name_plural = verbose_name
        ordering = ['-pub_date']

class Like(models.Model):
    note = models.ForeignKey(Note, on_delete=models.CASCADE, verbose_name='评论主题')
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='评论用户')
    state = models.BooleanField(default=False,verbose_name='点赞状态')

    class Meta:
        verbose_name = '点赞'
        verbose_name_plural = verbose_name